﻿using Minecraft.Config;
using Minecraft.Config.Csv.CsvCls;
using Minecraft.Config.Csv.CsvCom;
using Minecraft.Model;
using Minecraft.Model.Furniture;
using Minecraft.Model.ReqResp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Minecraft.ServerHall
{
	public static class FurnitureOutputExt
	{
		/// <summary>
		/// 判断goodsItemId是否是产出家具配方的一种
		/// </summary>
		/// <param name="furniture"></param>
		/// <param name="goodsItemId"></param>
		/// <returns></returns>
		public static bool isFurnitureOutputRecipe(this FurnitureModel furniture, string goodsItemId)
		{
			Mod_Drawing mod_Furniture = furniture.GetMod_FurnitureInfo();
			if (mod_Furniture == null)
			{
				return false;
			}
			//得到配方列表
			List<Mod_Compositing> mod_CompositingList = mod_Furniture.GetCompositingList_Convert(furniture.Level);
			var isRecipe = false;
			foreach (var mod_Compositing in mod_CompositingList)
			{
				var modRecipeInfoList = mod_Compositing.modRecipeInfoList_Convert;
				if (modRecipeInfoList.Any(m => m.GoodsItemId == goodsItemId))
				{
					isRecipe = true;
					break;
				}
			}
			return isRecipe;
		}
		/// <summary>
		/// 获取产出家具满足产出条件后的配方Id和所花的时间（如果不满足产出条件，则返回null）（主要时得到产出周期，产出周期依赖家具当前等级下的产出效率）
		/// </summary>
		/// <param name="furniture"></param>
		/// <returns></returns>
		public static ModRecipeTimeInfo GetFurnitureOutputModRecipeTimeInfo(this FurnitureModel furniture, MinecraftSession session, Mod_Compositing mod_Compositing)
		{
			//获取家具的配置信息
			Mod_Drawing mod_Furniture = furniture.GetMod_FurnitureInfo();
			if (mod_Compositing != null)
			{
				//获取家具满足产出条件后的配方Id以及产出周期
				ModRecipeTimeInfo modRecipeTimeInfo = mod_Furniture.GetOutputModRecipeTimeInfoList_Convert(furniture.Level).FirstOrDefault(m => m.RecipeId == mod_Compositing.Id);
				modRecipeTimeInfo.Second = Convert.ToInt32(modRecipeTimeInfo.Second * 1.0 / mod_Furniture.GetEfficiency_Convert(furniture.Level));
				return modRecipeTimeInfo;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 返回家具移动操作的物品类型响应的状态（用于数据合法性验证：enumGoodsBelongsToType、goodsPosition）
		/// </summary>
		/// <param name="enumGoodsBelongsToType"></param>
		/// <param name="goodsPosition"></param>
		/// <param name="session"></param>
		/// <returns></returns>
		public static BaseResp GetFurnitureGoodsMovePosBelongsToTypeBaseType(this EnumGoodsBelongsToType enumGoodsBelongsToType,
			string furnitureId, int goodsPosition, MinecraftSession session, string tips)
		{
			switch (enumGoodsBelongsToType)
			{
				case EnumGoodsBelongsToType.ShortcutBar:
					{
						if (goodsPosition < 0 || goodsPosition >= MinecraftConfig.ShortcutBarCellInitNum)
						{
							return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误（原因：GoodsPosition非法0【{tips}】）" };
						}
					}
					break;
				case EnumGoodsBelongsToType.Backpack:
					{
						if (goodsPosition < 0 || goodsPosition >= session.minecraftSessionInfo.BackpackCellNum)
						{
							return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误（原因：GoodsPosition非法1【{tips}】）" };
						}
					}
					break;
				case EnumGoodsBelongsToType.FurnitureOutput:
					{
						//获取家具的基本信息
						var furniture = session.minecraftSessionInfo.furnitureOutputList.FirstOrDefault(m => m.FurnitureId == furnitureId);
						//获取家具的配置信息
						var csvFurnitureItemInfo = furniture.GetMod_FurnitureInfo();
						if (csvFurnitureItemInfo == null)
						{
							return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误（原因：找不该类型【FurnitureItemId：{furniture.FurnitureItemId}】的家具，可能家具配置表配置不正确【{tips}】）" };
						}
						var cellTotalNum = csvFurnitureItemInfo.GetCellTotalNum_Convert(furniture.Level);
						var pos = cellTotalNum - 1;
						if (goodsPosition < 0 || goodsPosition > pos)
						{
							return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误（原因：GoodsPosition非法4，goodsPosition超出范围【enumGoodsBelongsToType：{enumGoodsBelongsToType.ToString()}，goodsPosition：{goodsPosition}，pos：{pos}】【{tips}】）" };
						}
					}
					break;
				case EnumGoodsBelongsToType.FurnitureOutputUpgrade:
					{
						//获取家具的基本信息
						var furniture = session.minecraftSessionInfo.furnitureOutputList.FirstOrDefault(m => m.FurnitureId == furnitureId);
						//获取家具的配置信息
						var csvFurnitureItemInfo = furniture.GetMod_FurnitureInfo();
						if (csvFurnitureItemInfo == null)
						{
							return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误（原因：找不该类型【FurnitureItemId：{furniture.FurnitureItemId}】的家具，可能家具配置表配置不正确【{tips}】）" };
						}
						var pos = furniture.GetFurnitureOutputUpgradeMaterialGoodsInfoList_Convert().Count() - 1;
						if (goodsPosition < 0 || goodsPosition > pos)
						{
							return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误（原因：GoodsPosition非法4，goodsPosition超出范围【enumGoodsBelongsToType：{enumGoodsBelongsToType.ToString()}，goodsPosition：{goodsPosition}，pos：{pos}】【{tips}】）" };
						}
					}
					break;
				case EnumGoodsBelongsToType.FurnitureOutputRepair:
					{
						//获取家具的基本信息
						var furniture = session.minecraftSessionInfo.furnitureOutputList.FirstOrDefault(m => m.FurnitureId == furnitureId);
						//获取家具的配置信息
						var csvFurnitureItemInfo = furniture.GetMod_FurnitureInfo();
						if (csvFurnitureItemInfo == null)
						{
							return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误（原因：找不该类型【FurnitureItemId：{furniture.FurnitureItemId}】的家具，可能家具配置表配置不正确【{tips}】）" };
						}
						var pos = furniture.GetFurnitureOutputRepairMaterialGoodsInfoList_Convert().Count() - 1;
						if (goodsPosition < 0 || goodsPosition > pos)
						{
							return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误（原因：GoodsPosition非法4，goodsPosition超出范围【enumGoodsBelongsToType：{enumGoodsBelongsToType.ToString()}，goodsPosition：{goodsPosition}，pos：{pos}】【{tips}】）" };
						}
					}
					break;
				default:
					{
						return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = $"错误（原因：物品类型不正确，或者暂不支持【enumGoodsBelongsToType：{enumGoodsBelongsToType}】【{tips}】）" };
					}
			}
			return new BaseResp { RespLevel = RespLevelEnum.Success };
		}

		/// <summary>
		/// 获取产出家具的材料的最大的可放置的position
		/// </summary>
		/// <param name="furniture"></param>
		/// <returns></returns>
		public static int GetFurnitureOutputMaterialMaxPosition(this FurnitureModel furniture)
		{
			Mod_Drawing csvFurnitureInfo = furniture.GetMod_FurnitureInfo();
			if (csvFurnitureInfo == null) //家具表中该家具配置不存在，则数据库信息存在错误，或者配置表出现错误
			{
				throw new Exception("csvFurnitureInfo 家具配置表 不存在该家具信息");
			}
			if (csvFurnitureInfo.enumFurnitureType_Convert != EnumFurnitureType.Output)
			{
				throw new Exception("csvFurnitureInfo 家具配置表 该家具不是产出家具");
			}
			var materialMaxPosition = 0;
			if (csvFurnitureInfo.If_buring_Convert)
			{
				materialMaxPosition = csvFurnitureInfo.GetCellTotalNum_Convert(furniture.Level) - 3;
			}
			else
			{
				materialMaxPosition = csvFurnitureInfo.GetCellTotalNum_Convert(furniture.Level) - 2;
			}
			return materialMaxPosition;
		}

		/// <summary>
		/// 针对 Output_MaterialGoodsItemIdsPosAndNums 字段转换成产出家具已经有的材料物品信息列表
		/// </summary>
		/// <param name="furniture"></param>
		/// <returns></returns>
		public static List<FurnitureOutputMaterialGoodsInfo> GetFurnitureOutputMaterialGoodsInfoList_Convert(this FurnitureModel furniture)
		{
			if (furniture.Output_MaterialGoodsItemIdsPosAndNums.Contains("#"))
			{
				List<FurnitureOutputMaterialGoodsInfo> furnitureOutputMaterialGoodsInfoList = new List<FurnitureOutputMaterialGoodsInfo>();
				var itemidsAndNumsStrs = furniture.Output_MaterialGoodsItemIdsPosAndNums.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
				foreach (var itemidsAndNumsStr in itemidsAndNumsStrs)
				{
					var idsAndNums = itemidsAndNumsStr.Split(new char[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
					FurnitureOutputMaterialGoodsInfo furnitureOutputMaterialGoodsInfo = new FurnitureOutputMaterialGoodsInfo
					{
						GoodsItemId = idsAndNums[0],
						GoodsPosition = int.Parse(idsAndNums[1]),
						Num = int.Parse(idsAndNums[2])
					};
					furnitureOutputMaterialGoodsInfoList.Add(furnitureOutputMaterialGoodsInfo);
				}
				return furnitureOutputMaterialGoodsInfoList;
			}
			else
			{
				return new List<FurnitureOutputMaterialGoodsInfo>();
			}
		}


		/// <summary>
		/// 针对Output_MaterialGoodsItemIdsPosAndNums字段的修改要从对象列表转换成字符串
		/// </summary>
		/// <param name="furniture"></param>
		/// <param name="furnitureOutputMaterialGoodsInfo"></param>
		public static void TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(this FurnitureModel furniture,
			FurnitureOutputMaterialGoodsInfo furnitureOutputMaterialGoodsInfo)
		{
			var list = furniture.GetFurnitureOutputMaterialGoodsInfoList_Convert();
			var index = list.FindIndex(m => m.GoodsPosition == furnitureOutputMaterialGoodsInfo.GoodsPosition);
			if (index >= 0)
			{
				list.RemoveAt(index);
			}
			if (furnitureOutputMaterialGoodsInfo.Num > 0)
			{
				list.Add(furnitureOutputMaterialGoodsInfo);
			}
			furniture.Output_MaterialGoodsItemIdsPosAndNums = string.Join("|", list.ToList().ConvertAll(info =>
			{
				return string.Join("#", info.GoodsItemId, info.GoodsPosition, info.Num);
			}).ToArray());
		}


		/// <summary>
		/// 判断家具是否满足产出条件
		/// </summary>
		/// <param name="furniture"></param>
		/// <param name="session"></param>
		/// <param name="canOutputCompositing"></param>
		/// <returns></returns>
		public static bool JudgeAchieveOutputConditions(this FurnitureModel furniture,
			MinecraftSession session, out Mod_Compositing canOutputCompositing)
		{
			bool isCanAchieveOutput = false;
			//找到可以产出的配方信息
			canOutputCompositing = null;
			//Mod_Items mod_Items = CsvConfig.itemsList.FirstOrDefault(m => m.Id == furniture.Output_ResultGoodsItemId);
			Mod_Items mod_Items = CsvConfig.GetMod_ItemsInfoById(furniture.Output_ResultGoodsItemId);
			if (mod_Items != null)
			{
				//从配置中读取指定物品存放数量上限
				var goodsItemMaxNum = session.GetMaxCellNumConvert(furniture.Output_ResultGoodsItemId);
				if (furniture.Output_ResultGoodsNum >= goodsItemMaxNum)
				{
					return false;
				}
			}

			//产出家具中现有材料列表
			var furnitureMaterialList = furniture.GetFurnitureOutputMaterialGoodsInfoList_Convert();
			//家具配置信息
			Mod_Drawing csvFurnitureInfo = furniture.GetMod_FurnitureInfo();
			if (csvFurnitureInfo == null) //家具表中该家具配置不存在，则数据库信息存在错误，或者配置表出现错误
			{
				string errorTips = $"指定家具配置信息不存在（FurnitureItemId：【{furniture.FurnitureItemId}】）";
				session.AppServer.Logger.Fatal(errorTips);
				return isCanAchieveOutput;
			}
			var csvCompositingList = csvFurnitureInfo.GetCompositingList_Convert(furniture.Level);
			if (csvCompositingList == null || !csvCompositingList.Any())
			{
				string errorTips = $"【配置表错误】指定家具指定等级的配方列表信息不存在（FurnitureItemId：【{furniture.FurnitureItemId}】 指定等级：【{furniture.Level}】）";
				session.AppServer.Logger.Fatal(errorTips);
				throw new Exception(errorTips); //【配置表错误】直接异常
			}

			foreach (var csvCompositing in csvCompositingList)
			{
				canOutputCompositing = csvCompositing; //先假设该配方可以达到产出条件
				if (csvCompositing.modRecipeInfoList_Convert == null || !csvCompositing.modRecipeInfoList_Convert.Any())
				{
					string errorTips = $"【配置表错误】指定家具指定等级的指定配方的所需物品ItemId和个数信息不存在（FurnitureItemId：【{furniture.FurnitureItemId}】 指定等级：【{furniture.Level}】产出家具的配方表Id：【{csvCompositing.Id}】）";
					session.AppServer.Logger.Fatal(errorTips);
					throw new Exception(errorTips); //【配置表错误】直接异常
				}
				//遍历指定配方信息中的所需物品itemid和个数信息列表
				foreach (var recipeInfo in csvCompositing.modRecipeInfoList_Convert)
				{
					//判断产出家具中现有材料列表，只要有一个recipeInfo不满足，则表示不能执行产出流程
					var materialMaxPosition = furniture.GetFurnitureOutputMaterialMaxPosition();
					var furnitureMaterialInfo = furnitureMaterialList.FirstOrDefault(m =>
						m.GoodsItemId == recipeInfo.GoodsItemId
						&& m.GoodsPosition <= materialMaxPosition);
					if (furnitureMaterialInfo == null || furnitureMaterialInfo.Num < recipeInfo.Num)
					{
						canOutputCompositing = null;
						break;
					}
				}
				if (canOutputCompositing != null)
				{
					break;
				}
			}
			if (canOutputCompositing != null)
			{
				//达到了产出条件
				isCanAchieveOutput = true;
				var mod_Compositing = canOutputCompositing;
				//得到产物itemId
				furniture.Output_ResultGoodsItemId = mod_Compositing.Product;
			}
			return isCanAchieveOutput;
		}
		/// <summary>
		/// 判断产出家具中的燃料是否足够
		/// </summary>
		/// <param name="furniture"></param>
		/// <param name="If_buring_Convert">是否需要燃料</param>
		/// <param name="fuelInfo">燃料信息</param>
		/// <returns></returns>
		public static bool JudgeFurnitureOutputFuelEnough(this FurnitureModel furniture, out bool If_buring_Convert, out FurnitureOutputMaterialGoodsInfo fuelInfo)
		{
			fuelInfo = null; //燃料信息
			If_buring_Convert = false; //是否需要燃料
			Mod_Drawing csvFurnitureItemInfo = furniture.GetMod_FurnitureInfo();
			if (csvFurnitureItemInfo.If_buring_Convert) //如果家具需要燃料
			{
				If_buring_Convert = true;
				var materialGoodsInfoList = furniture.GetFurnitureOutputMaterialGoodsInfoList_Convert();
				//根据燃料放置位置判断
				var furnitureOutputMaterialGoodsInfo = materialGoodsInfoList.FirstOrDefault(m => m.GoodsPosition == csvFurnitureItemInfo.GetCellTotalNum_Convert(furniture.Level) - 2);
				if (furnitureOutputMaterialGoodsInfo != null)
				{
					if (furnitureOutputMaterialGoodsInfo.Num > 0)
					{
						fuelInfo = furnitureOutputMaterialGoodsInfo;
						return true;
					}
					else
					{
						return false;
					}
				}
				else
				{
					return false;
				}
			}
			else //如果家具不需要燃料
			{
				return false;
			}
		}
		/// <summary>
		/// 得到燃料格子中的燃料信息。如果产出家具需要燃料，并且材料字段中有燃料信息，并且燃料放在了燃料格子里，则得到燃料格子中的燃料信息（goodsItemId、num），否则返回null
		/// </summary>
		public static FurnitureOutputMaterialGoodsInfo GetFurnitureOutputFuelInfo(this FurnitureModel furniture)
		{
			//家具的配置信息（包含是否需要燃料等）
			Mod_Drawing csvFurnitureInfo = furniture.GetMod_FurnitureInfo();
			if (csvFurnitureInfo.If_buring_Convert) //如果需要燃料
			{
				//找到可以存放燃料的位置
				var fuelPosition = csvFurnitureInfo.GetCellTotalNum_Convert(furniture.Level) - 2;
				//在可以存放燃料的位置上找到物品信息
				var furnitureOutputMaterialGoodsInfo = furniture.GetFurnitureOutputMaterialGoodsInfoList_Convert().FirstOrDefault(m => m.GoodsPosition == fuelPosition && m.Num > 0);

				if (furnitureOutputMaterialGoodsInfo != null) //如果存在 在可以存放燃料的位置上找到物品信息
				{
					//如果当前燃料格子中有物品，再判断这个物品是不是燃料
					//var fuelInfo = CsvConfig.itemsList.FirstOrDefault(k => k.Id == furnitureOutputMaterialGoodsInfo.GoodsItemId && k.modAttributeInfo_Convert.enumAttribute == EnumAttribute.BurnVal);
					var fuelInfo = CsvConfig.GetMod_ItemsInfoById(furnitureOutputMaterialGoodsInfo.GoodsItemId);
					if (fuelInfo != null && fuelInfo.modAttributeInfo_Convert.enumAttribute == EnumAttribute.BurnVal) //如果如果当前处于是燃料
					{
						return furnitureOutputMaterialGoodsInfo;
					}
					else
					{
						return null;
					}
				}
				else
				{
					return null;
				}
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 得到一个燃料的燃烧周期。如果产出家具需要燃料，并且燃料格子中有燃料，则得到一个燃料的燃烧周期；如果条件不满足，则返回-1
		/// </summary>
		public static int GetFurnitureOutputFuelCycleSecond(this FurnitureModel furniture)
		{
			//家具的配置信息（包含是否需要燃料等）
			Mod_Drawing csvFurnitureInfo = furniture.GetMod_FurnitureInfo();
			if (csvFurnitureInfo.If_buring_Convert)
			{
				var furnitureFuelInfo = furniture.GetFurnitureOutputFuelInfo();
				if (furnitureFuelInfo != null)
				{
					//var fuelInfo = CsvConfig.itemsList.FirstOrDefault(k => k.Id == furnitureFuelInfo.GoodsItemId);
					var fuelInfo = CsvConfig.GetMod_ItemsInfoById(furnitureFuelInfo.GoodsItemId);
					if (fuelInfo.modAttributeInfo_Convert != null)
					{
						return fuelInfo.modAttributeInfo_Convert.Value;
					}
					else
					{
						return -1;
					}
				}
				else
				{
					return -1;
				}
			}
			else
			{
				return -1;
			}
		}

		/// <summary>
		/// 获取产出家具中的燃料的燃烧状态
		/// </summary>
		/// <param name="furniture"></param>
		public static EnumFuelBurnState GetFurnitureOutputFuelBurnState(this FurnitureModel furniture, MinecraftSession session)
		{
			EnumFuelBurnState enumFuelBurnState = EnumFuelBurnState.Unknown;
			bool isCanAchieveOutput = furniture.JudgeAchieveOutputConditions(session, out Mod_Compositing mod_Compositing);
			bool isFuelEnough = furniture.JudgeFurnitureOutputFuelEnough(out bool If_buring_Convert, out FurnitureOutputMaterialGoodsInfo fuelInfo);
			if (If_buring_Convert) //如果家具需要燃料
			{
				if (isCanAchieveOutput) //如果满足产出条件
				{
					if (isFuelEnough) //如果燃料足够
					{
						enumFuelBurnState = EnumFuelBurnState.InTheCombustion;
					}
					else //如果燃料不够
					{
						enumFuelBurnState = EnumFuelBurnState.Unburned;
					}
				}
				else //如果不满足产出条件
				{
					//不作处理
					//enumFuelBurnState = furniture.sta
				}
			}
			else //如果家具不需要燃料
			{
				enumFuelBurnState = EnumFuelBurnState.Unknown;
			}
			return enumFuelBurnState;
		}

		/// <summary>
		/// 获取产出家具产出状态
		/// </summary>
		/// <param name="furniture"></param>
		/// <param name="session"></param>
		/// <returns></returns>
		public static EnumFurnitureOutputState GetFurnitureOutputState(this FurnitureModel furniture, MinecraftSession session)
		{
			EnumFurnitureOutputState enumFurnitureOutputState = EnumFurnitureOutputState.NotStart;
			bool isCanAchieveOutput = furniture.JudgeAchieveOutputConditions(session, out Mod_Compositing mod_Compositing);
			EnumFuelBurnState enumFuelBurnState = furniture.GetFurnitureOutputFuelBurnState(session);
			Mod_Drawing csvFurnitureInfo = furniture.GetMod_FurnitureInfo();
			if (isCanAchieveOutput) //如果满足产出条件
			{
				if (csvFurnitureInfo.If_buring_Convert) //如果家具需要燃料
				{
					if (enumFuelBurnState == EnumFuelBurnState.InTheCombustion) //如果燃料状态为【燃烧中】
					{
						enumFurnitureOutputState = EnumFurnitureOutputState.Progressing;
					}
					else if (enumFuelBurnState == EnumFuelBurnState.Unburned) //如果燃料状态为【未燃烧】
					{
						enumFurnitureOutputState = EnumFurnitureOutputState.PauseIn;
					}
					else //不做处理
					{

					}
				}
				else //如果家具不需要燃料
				{
					enumFurnitureOutputState = EnumFurnitureOutputState.Progressing;
				}
			}
			else //如果不满足产出条件
			{
				enumFurnitureOutputState = EnumFurnitureOutputState.NotStart;
			}
			return enumFurnitureOutputState;
		}

		/// <summary>
		/// 计算产出家具的物品变化（当前的材料信息，产物信息）
		/// </summary>
		/// <param name="furniture"></param>
		public static BaseResp CalculateFurnitureOutputChange(this FurnitureModel furniture, int resultNum, Mod_Compositing mod_Compositing)
		{
			//家具中现有材料列表
			var furnitureMaterialList = furniture.GetFurnitureOutputMaterialGoodsInfoList_Convert();
			//累加产物个数
			furniture.Output_ResultGoodsNum += resultNum;
			//计算材料的消耗
			for (int i = 0; i < resultNum; i++)
			{
				foreach (var recipeInfo in mod_Compositing.modRecipeInfoList_Convert) //配方个数比较小
				{
					var furnitureMaterialInfo = furnitureMaterialList.FirstOrDefault(m => m.GoodsItemId == recipeInfo.GoodsItemId);
					if (furnitureMaterialInfo == null)
					{
						return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：计算时 furnitureMaterialInfo 结果为空）" };
					}
					furnitureMaterialInfo.Num -= recipeInfo.Num;
					if (furnitureMaterialInfo.Num < 0)
					{
						return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：材料数量的变化到小于0的值，非法）" };
					}
					furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(furnitureMaterialInfo);
				}
			}
			return new BaseResp() { RespLevel = RespLevelEnum.Success, Msg = "" };
		}



		/// <summary>
		/// 获取产出家具产出信息
		/// </summary>
		/// <param name="furniture"></param>
		/// <param name="session"></param>
		/// <param name="furnitureOutputInfo"></param>
		/// <returns></returns>
		public static BaseResp GetFurnitureOutputInfo(this FurnitureModel furniture, MinecraftSession session, out FurnitureOutputInfo furnitureOutputInfo)
		{
			furnitureOutputInfo = null;

			var timeNow = DateTimeOffset.Now;
			var separatorChar = '|';

			/*
			 * 根据timeTicksStr的分段得到当前的产出信息，即：
			 * 材料列表、材料格子、是否需要燃料、现有燃料个数、现有产物
			 */

			List<DateTime> tickList = furniture.Output_timeTicksStr.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(m => new DateTime(long.Parse(m))).ToList();

			//if (JsonConfig.Value.IsDebug)
			//{
			//	tickList.Clear();
			//	tickList.Add(timeNow.AddSeconds(-(240 * 1 + 1)));
			//	furniture.MaterialGoodsItemIdsPosAndNums = "100004#0#8";
			//	furniture.ResultGoodsItemId = "6&0";
			//	furniture.ResultGoodsNum = 1;
			//}

			//if (JsonConfig.Value.IsDebug)
			//{
			//	furniture.MaterialGoodsItemIdsPosAndNums = "100000#0#6|100001#1#8|100000#2#10";
			//	//furniture.MaterialGoodsItemIdsPosAndNums = "100000#0#6";
			//	tickList.Clear();
			//	tickList.Add(timeNow.AddSeconds(-(240 * 0 + 1)));
			//	furniture.ResultGoodsNum = 0;
			//	//furniture.ResultGoodsItemId = "140000";
			//	furniture.ResultGoodsItemId = "";
			//}

			//当前是否满足产出条件，out出配方信息 mod_Compositing
			var IsCurAchieveOutputConditions = furniture.JudgeAchieveOutputConditions(session, out Mod_Compositing mod_Compositing);
			//获取家具满足产出条件后的配方Id和单轮产出所花的时间的信息（如果不满足产出条件，则返回null）
			ModRecipeTimeInfo modRecipeTimeInfo = furniture.GetFurnitureOutputModRecipeTimeInfo(session, mod_Compositing);
			//家具的配置信息（包含是否需要燃料等）
			Mod_Drawing csvFurnitureInfo = furniture.GetMod_FurnitureInfo();
			//家具是否需要燃料
			var If_buring_Convert = csvFurnitureInfo.If_buring_Convert;


			//---临时存放变量开始---

			//存储家具的产出状态
			EnumFurnitureOutputState enumFurnitureOutputState = EnumFurnitureOutputState.NotStart;
			//燃烧产出状态
			EnumFuelBurnState enumFuelBurnState = EnumFuelBurnState.Unknown;
			//配方产出周期
			var formulationOutputCycleSecond = 0;
			//产出剩余时间（单位：秒）（剩余时间衰减与产出效率相关联）
			var outputRemainSecond = 0;
			//燃料itemId
			var FuelGoodsItemId = "";
			//一个燃料的燃烧周期（单位：秒）
			var fuelBurnCycleSecond = 0;
			//燃料物品所剩个数（正处于燃烧的那个也算进去了）
			var FuelRemainNum = 0;
			//一个燃料的燃烧剩余时间（如果燃料正在燃烧，用于倒计时显示）
			var burnRemainSecond = 0;

			//---临时存放变量结束---


			if (tickList == null || !tickList.Any())
			{
				//此时状态：当前时间点前一刻的状态为 NotStart，燃烧状态：未燃烧
				enumFurnitureOutputState = EnumFurnitureOutputState.NotStart;
				enumFuelBurnState = EnumFuelBurnState.Unburned;
			}
			else
			{
				if (modRecipeTimeInfo == null)
				{
					return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：获取家具满足产出条件后的配方Id和单轮产出所花的时间的信息失败）" };
				}
				//配方产出周期
				formulationOutputCycleSecond = modRecipeTimeInfo.Second;
				//先计算可以产出几轮（也就是说，在不考虑燃料的情况下，或者说可以得到几个产物，考虑产物格子容量）
				var canResultNum = 0; //存储利用材料最多可以生成多少个产物
				var resultNumList = new List<int>();
				//家具中现有材料列表
				var furnitureMaterialList = furniture.GetFurnitureOutputMaterialGoodsInfoList_Convert();
				foreach (var recipeInfo in mod_Compositing.modRecipeInfoList_Convert) //配方个数比较小
				{
					//材料个数比较多（因此：材料个数除以配方个数）
					var furnitureMaterialInfo = furnitureMaterialList.FirstOrDefault(m => m.GoodsItemId == recipeInfo.GoodsItemId);
					if (furnitureMaterialInfo == null)
					{
						return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：furnitureMaterialInfo timeticks 不为空时 材料信息为空，获取材料信息失败）" };
					}
					if (furnitureMaterialInfo.Num <= 0)
					{
						return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：furnitureMaterialInfo timeticks 不为空时 furnitureMaterialInfo.Num <= 0）" };
					}
					resultNumList.Add(furnitureMaterialInfo.Num / recipeInfo.Num);
				}
				if (resultNumList.Count() == 1)
				{
					canResultNum = resultNumList.First();
				}
				else
				{
					canResultNum = resultNumList.Min(); //取最小值
				}
				//最终的产物个数 finalResultNum：canResultNum再与产物格子中的已有数量和容量上限作对比，得到最终的可以产出的产物个数
				var finalResultNum = Math.Min(canResultNum + furniture.Output_ResultGoodsNum, session.GetMaxCellNumConvert(mod_Compositing.Product)) - furniture.Output_ResultGoodsNum;

				//---产出部分结束---


				var tickCount = tickList.Count();
				if (tickCount % 2 == 1) //存入了 开始，或者 开始|暂停|继续
				{
					//tickList存值的最后一项：产出开始或者继续

					//当前时间点有可能产出还在继续、或者产出暂停、或者产出已经终止了
					//根据已有材料以及燃料来判断

					//得到开始产出时间
					var startTime = tickList.FirstOrDefault();

					//得到中间暂停的时间
					var suspendSeconds = 0;
					if (tickCount >= 3)
					{
						for (int i = 1; i < tickList.Count(); i = i + 2)
						{
							var suspendTime = tickList[i];
							var continueTime = tickList[i + 1];
							suspendSeconds += Convert.ToInt32((continueTime - suspendTime).TotalSeconds);
						}
					}

					//得到当前时间与产出开始时间的差值 int类型（单位：秒）（不包括暂停时间）
					var startTimenowTotalSeconds = Convert.ToInt32((timeNow - startTime).TotalSeconds);
					startTimenowTotalSeconds -= suspendSeconds; //减去中间暂停的时间

					//重新计算单轮开始产出时间，或者清空timeticks
					var divide1 = startTimenowTotalSeconds / formulationOutputCycleSecond;
					if (divide1 >= 1) //已经进行了1轮以上的产出
					{

					}

					//计算出家具产出到达时间
					var outputTargetTime = startTime.AddSeconds(formulationOutputCycleSecond * finalResultNum);


					//计算 如果需要燃料的情况下，燃料总共可以燃烧多久
					if (If_buring_Convert)//如果家具需要燃料
					{

						//---燃料部分开始---

						//得到一个燃料的燃烧周期
						var fuelCycleSecond = furniture.GetFurnitureOutputFuelCycleSecond();
						if (fuelCycleSecond <= 0)
						{
							return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：获取一个燃料的燃烧周期失败）" };
						}
						fuelBurnCycleSecond = fuelCycleSecond;
						//燃料信息
						var fuelInfo = furniture.GetFurnitureOutputFuelInfo();
						if (fuelInfo == null)
						{
							return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：产出家具中燃料信息不存在）" };
						}
						FuelGoodsItemId = fuelInfo.GoodsItemId;
						//计算出利用现有燃料燃烧完成后所到达的时间点
						var fuelTimeto = startTime.AddSeconds(fuelCycleSecond * fuelInfo.Num);

						//---燃料部分结束---


						//---时间判断开始---

						//接下来就对比三个时间（计算每种情况下的家具格子中的信息变化，并重新赋值）
						if (outputTargetTime < timeNow)//产出到达时间小于当前时间
						{
							if (outputTargetTime < fuelTimeto)//产出到达时间小于燃烧结束时间
							{
								if (fuelTimeto < timeNow)//燃烧结束时间小于当前时间
								{
									//此时状态：产出结束状态，燃料燃烧状态一定是未燃烧状态
									enumFurnitureOutputState = EnumFurnitureOutputState.NotStart;
									enumFuelBurnState = EnumFuelBurnState.Unburned;
									//计算变化：
									var baseResp = furniture.CalculateFurnitureOutputChange(finalResultNum, mod_Compositing);
									if (baseResp.RespLevel != RespLevelEnum.Success)
									{
										return baseResp;
									}
									//计算燃料的具体情况
									//计算已经燃烧了几个燃料（有临界点）
									var fuelBurnNum = Convert.ToInt32((outputTargetTime - startTime).TotalSeconds) / fuelCycleSecond;
									if (fuelBurnNum > fuelInfo.Num)
									{
										return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：得到已经燃烧过的燃料的个数不合法）" };
									}
									fuelInfo.Num -= fuelBurnNum;
									//可能产出结束后的时间点燃料还处于燃烧状态，则还要减去1
									if (Convert.ToInt32((outputTargetTime - startTime).TotalSeconds) % fuelCycleSecond != 0)
									{
										fuelInfo.Num--;
									}
									furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(fuelInfo);
									//初始化timeTicksStr
									furniture.Output_timeTicksStr = "";
								}
								else//燃烧结束时间大于等于当前时间
								{
									//此时状态：产出结束状态，但是燃料燃烧状态不确定是不是在燃烧中
									enumFurnitureOutputState = EnumFurnitureOutputState.NotStart;
									//计算变化：
									var baseResp = furniture.CalculateFurnitureOutputChange(finalResultNum, mod_Compositing);
									if (baseResp.RespLevel != RespLevelEnum.Success)
									{
										return baseResp;
									}
									//计算燃料的具体情况
									//计算已经燃烧了几个燃料
									var fuelBurnNum = Convert.ToInt32((outputTargetTime - startTime).TotalSeconds) / fuelCycleSecond;
									if (fuelBurnNum > fuelInfo.Num)
									{
										return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：得到已经燃烧过的燃料的个数不合法）" };
									}
									fuelInfo.Num -= fuelBurnNum;
									furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(fuelInfo);

									if (Convert.ToInt32((timeNow - startTime).TotalSeconds) % fuelCycleSecond == 0)
									{
										//临界点，产出到达时间区间以与燃烧倍数的周期 相等
										//此时燃烧状态为  未燃烧状态
										enumFuelBurnState = EnumFuelBurnState.Unburned;
									}
									else
									{
										var fuelBurnNumAddOneSeconds = fuelCycleSecond * (fuelBurnNum + 1);
										var fuelBurnNumAddOneTime = startTime.AddSeconds(fuelBurnNumAddOneSeconds);
										if (fuelBurnNumAddOneTime <= timeNow)
										{
											//此时状态为 未燃烧状态
											enumFuelBurnState = EnumFuelBurnState.Unburned;
										}
										else
										{
											//此时状态为 正在燃烧中
											enumFuelBurnState = EnumFuelBurnState.InTheCombustion;
											burnRemainSecond = Convert.ToInt32((fuelBurnNumAddOneTime - timeNow).TotalSeconds);
										}
									}
									//初始化timeTicksStr
									furniture.Output_timeTicksStr = "";
								}
							}
							else//产出到达时间大于等于燃烧结束时间
							{
								if (fuelTimeto < timeNow)//燃烧结束时间小于当前时间
								{
									//燃料已经全部用完，燃烧状态为 未燃烧
									enumFuelBurnState = EnumFuelBurnState.Unburned;
									//但是此时产出状态不确定（在临界点时为产出停止状态，不在临界点时为暂停状态）
									//原来的燃料个数
									int originalFuelNum = fuelInfo.Num;
									if (originalFuelNum <= 0)
									{
										return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：originalFuelNum 原来的燃料个数不能小于等于0）" };
									}
									//更新燃料信息
									fuelInfo.Num = 0;
									furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(fuelInfo);
									//更新材料信息
									//在燃料燃烧时间内，可以得到几个产物
									var resultNum = Convert.ToInt32((fuelTimeto - startTime).TotalSeconds / formulationOutputCycleSecond);
									//计算变化：
									var baseResp = furniture.CalculateFurnitureOutputChange(resultNum, mod_Compositing);
									if (baseResp.RespLevel != RespLevelEnum.Success)
									{
										return baseResp;
									}
									if (outputTargetTime == fuelTimeto)
									{
										//产出停止状态
										enumFurnitureOutputState = EnumFurnitureOutputState.NotStart;
										//初始化timeTicksStr
										furniture.Output_timeTicksStr = "";
									}
									else
									{
										//产出暂停状态
										enumFurnitureOutputState = EnumFurnitureOutputState.PauseIn;
										outputRemainSecond = Convert.ToInt32((outputTargetTime - fuelTimeto).TotalSeconds);





										///////////////////////----------------已处理：timeTicksStr--------------------
										//对timeTicksStr重新赋值
										if (resultNum >= 1)
										{
											//一定为 开始|暂停 时间
											//前几轮完整的产出的持续时间
											var durationSeconds = resultNum * formulationOutputCycleSecond + suspendSeconds;
											//最近一轮的开始时间
											var newStartTime = startTime.AddSeconds(durationSeconds);
											var suspendTime = startTime.AddSeconds(originalFuelNum * fuelCycleSecond);
											if (newStartTime > suspendTime)
											{
												return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：newStartTime > suspendTime）" };
											}
											var beforeTicksList = new List<string> { newStartTime.Ticks.ToString(), suspendTime.Ticks.ToString() };
											furniture.Output_timeTicksStr = string.Join(separatorChar.ToString(), beforeTicksList.ToArray());
										}
										else
										{
											//开始|暂停  或者  开始|暂停|继续|暂停  ...（即加一个暂停时间）
											var beforeTicksList = furniture.Output_timeTicksStr.Split(new char[] { separatorChar }, StringSplitOptions.RemoveEmptyEntries).ToList();
											beforeTicksList.Add(startTime.AddSeconds(originalFuelNum * fuelCycleSecond).Ticks.ToString());
											furniture.Output_timeTicksStr = string.Join(separatorChar.ToString(), beforeTicksList.ToArray());
										}

									}
								}
								else//燃烧结束时间大于等于当前时间
								{
									//这种情况一定不存在
								}
							}
						}
						else//产出到达时间大于等于当前时间
						{
							if (outputTargetTime < fuelTimeto)//产出到达时间小于燃烧结束时间
							{
								if (fuelTimeto < timeNow)//燃烧结束时间小于当前时间
								{
									//这种情况一定不存在
								}
								else//燃烧结束时间大于等于当前时间
								{
									//产出状态不确定（可能处于停止状态，可能处于暂停状态），燃料燃烧状态也不确定（可能燃烧中，可能未燃烧）
									//计算变化
									var resultNum = startTimenowTotalSeconds / formulationOutputCycleSecond;
									var baseResp = furniture.CalculateFurnitureOutputChange(resultNum, mod_Compositing);
									if (baseResp.RespLevel != RespLevelEnum.Success)
									{
										return baseResp;
									}

									//计算燃料的具体情况
									//计算已经燃烧了几个燃料
									var fuelBurnNum = Convert.ToInt32((timeNow - startTime).TotalSeconds) / fuelCycleSecond;
									if (fuelBurnNum > fuelInfo.Num)
									{
										return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：得到已经燃烧过的燃料的个数不合法）" };
									}

									if (outputTargetTime == timeNow)
									{
										//此时状态一定处于停止状态
										enumFurnitureOutputState = EnumFurnitureOutputState.NotStart;
										if (Convert.ToInt32((timeNow - startTime).TotalSeconds) % fuelCycleSecond == 0)
										{
											//临界点，产出到达时间区间以与燃烧倍数的周期 相等
											//此时燃烧状态为  未燃烧状态
											enumFuelBurnState = EnumFuelBurnState.Unburned;
										}
										else
										{
											var fuelBurnNumAddOneSeconds = fuelCycleSecond * (fuelBurnNum + 1);
											var fuelBurnNumAddOneTime = startTime.AddSeconds(fuelBurnNumAddOneSeconds);
											if (fuelBurnNumAddOneTime <= timeNow)
											{
												//此时状态为 未燃烧状态
												enumFuelBurnState = EnumFuelBurnState.Unburned;
												fuelInfo.Num--;//（燃料个数临界点）
												furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(fuelInfo);
											}
											else
											{
												//此时状态为 正在燃烧中
												enumFuelBurnState = EnumFuelBurnState.InTheCombustion;
												burnRemainSecond = Convert.ToInt32((fuelBurnNumAddOneTime - timeNow).TotalSeconds);
											}
										}
										//初始化timeTicksStr
										furniture.Output_timeTicksStr = "";
									}
									else
									{
										//此时状态处于产出进行状态，燃料状态 正在燃烧中
										enumFurnitureOutputState = EnumFurnitureOutputState.Progressing;
										outputRemainSecond = Convert.ToInt32((outputTargetTime - timeNow).TotalSeconds);
										enumFuelBurnState = EnumFuelBurnState.InTheCombustion;





										var fuelBurnNum2 = Convert.ToInt32((outputTargetTime - startTime).TotalSeconds) / fuelCycleSecond;
										if (fuelBurnNum2 > fuelInfo.Num)
										{
											return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：fuelBurnNum2个数不合法）" };
										}
										var fuelBurnNumAddOneSeconds = fuelCycleSecond * (fuelBurnNum2 + 1);
										var fuelBurnNumAddOneTime = startTime.AddSeconds(fuelBurnNumAddOneSeconds);
										if (fuelBurnNumAddOneTime < outputTargetTime)
										{
											return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：fuelBurnNumAddOneTime < outputTargetTime）" };
										}
										else
										{
											burnRemainSecond = Convert.ToInt32((fuelBurnNumAddOneTime - timeNow).TotalSeconds);
										}



										///////////////////////----------------已处理：timeTicksStr--------------------
										//对timeTicksStr重新赋值
										if (resultNum >= 1)
										{
											//说明：这里有一个产出开始时间与燃料燃烧开始时间的小偏差，这里忽略不计
											//一定只有一个 开始 时间
											//计算开始的时刻
											furniture.Output_timeTicksStr = startTime.AddSeconds(resultNum * formulationOutputCycleSecond + suspendSeconds).Ticks.ToString();
										}
										else //还在该轮中，不做处理
										{
										}

									}
									fuelInfo.Num -= fuelBurnNum;
									furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(fuelInfo);
								}
							}
							else//产出到达时间大于等于燃烧结束时间
							{
								if (fuelTimeto < timeNow)//燃烧结束时间小于当前时间
								{
									//产出状态为 暂停状态，燃烧状态为未燃烧
									enumFurnitureOutputState = EnumFurnitureOutputState.PauseIn;
									enumFuelBurnState = EnumFuelBurnState.Unburned;
									//原来的燃料个数
									int originalFuelNum = fuelInfo.Num;
									if (originalFuelNum <= 0)
									{
										return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：originalFuelNum 原来的燃料个数不能小于等于0）" };
									}
									//更新燃料信息
									fuelInfo.Num = 0;
									furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(fuelInfo);
									var resultNum = Convert.ToInt32((fuelTimeto - startTime).TotalSeconds / formulationOutputCycleSecond);
									//计算变化：
									var baseResp = furniture.CalculateFurnitureOutputChange(resultNum, mod_Compositing);
									if (baseResp.RespLevel != RespLevelEnum.Success)
									{
										return baseResp;
									}
									outputRemainSecond = Convert.ToInt32((outputTargetTime - fuelTimeto).TotalSeconds);






									///////////////////////----------------已处理：timeTicksStr--------------------
									//对timeTicksStr重新赋值
									if (resultNum >= 1)
									{
										//一定为 开始|暂停 时间
										//前几轮完整的产出的持续时间
										var durationSeconds = resultNum * formulationOutputCycleSecond + suspendSeconds;
										//最近一轮的开始时间
										var newStartTime = startTime.AddSeconds(durationSeconds);
										var suspendTime = startTime.AddSeconds(originalFuelNum * fuelCycleSecond);
										if (newStartTime > suspendTime)
										{
											return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：newStartTime > suspendTime）" };
										}
										var beforeTicksList = new List<string> { newStartTime.Ticks.ToString(), suspendTime.Ticks.ToString() };
										furniture.Output_timeTicksStr = string.Join(separatorChar.ToString(), beforeTicksList.ToArray());
									}
									else
									{
										//开始|暂停  或者  开始|暂停|继续|暂停  ...（即加一个暂停时间）
										var beforeTicksList = furniture.Output_timeTicksStr.Split(new char[] { separatorChar }, StringSplitOptions.RemoveEmptyEntries).ToList();
										beforeTicksList.Add(startTime.AddSeconds(originalFuelNum * fuelCycleSecond).Ticks.ToString());
										furniture.Output_timeTicksStr = string.Join(separatorChar.ToString(), beforeTicksList.ToArray());
									}






								}
								else//燃烧结束时间大于等于当前时间
								{
									//产出状态为产出进行状态，燃烧状态不确定，存在临界点
									enumFurnitureOutputState = EnumFurnitureOutputState.Progressing;
									outputRemainSecond = Convert.ToInt32((outputTargetTime - timeNow).TotalSeconds);

									var resultNum = Convert.ToInt32((timeNow - startTime).TotalSeconds / formulationOutputCycleSecond);
									//计算变化：
									var baseResp = furniture.CalculateFurnitureOutputChange(resultNum, mod_Compositing);
									if (baseResp.RespLevel != RespLevelEnum.Success)
									{
										return baseResp;
									}

									//计算燃料的具体情况
									//计算已经燃烧了几个燃料
									var fuelBurnNum = Convert.ToInt32((timeNow - startTime).TotalSeconds) / fuelCycleSecond;
									if (fuelBurnNum > fuelInfo.Num)
									{
										return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：得到已经燃烧过的燃料的个数不合法）" };
									}
									fuelInfo.Num -= fuelBurnNum;
									furniture.TransformListToOutput_MaterialGoodsItemIdsPosAndNums_Convert(fuelInfo);

									if (Convert.ToInt32((timeNow - startTime).TotalSeconds) % fuelCycleSecond == 0)
									{
										//临界点，产出到达时间区间以与燃烧倍数的周期 相等
										//此时燃烧状态为  未燃烧状态
										enumFuelBurnState = EnumFuelBurnState.Unburned;
									}
									else
									{
										var fuelBurnNumAddOneSeconds = fuelCycleSecond * (fuelBurnNum + 1);
										var fuelBurnNumAddOneTime = startTime.AddSeconds(fuelBurnNumAddOneSeconds);
										if (fuelBurnNumAddOneTime <= timeNow)
										{
											//此时状态为 未燃烧状态
											enumFuelBurnState = EnumFuelBurnState.Unburned;
										}
										else
										{
											//此时状态为 正在燃烧中
											enumFuelBurnState = EnumFuelBurnState.InTheCombustion;
											burnRemainSecond = Convert.ToInt32((fuelBurnNumAddOneTime - timeNow).TotalSeconds);
										}
									}







									///////////////////////----------------已处理：timeTicksStr--------------------
									//对timeTicksStr重新赋值
									if (resultNum >= 1)
									{
										//说明：这里有一个产出开始时间与燃料燃烧开始时间的小偏差，这里忽略不计
										//一定只有一个 开始 时间
										//计算开始的时刻
										furniture.Output_timeTicksStr = startTime.AddSeconds(resultNum * formulationOutputCycleSecond + suspendSeconds).Ticks.ToString();
									}
									else //还在该轮中，不做处理
									{
									}






								}
							}
						}
						FuelRemainNum = fuelInfo.Num;
						//---时间判断结束---

					}
					else//如果家具不需要燃料
					{
						if (outputTargetTime < timeNow)//产出到达时间小于当前时间
						{
							//此时状态：产出停止
							enumFurnitureOutputState = EnumFurnitureOutputState.NotStart;
							//计算变化：
							var baseResp = furniture.CalculateFurnitureOutputChange(finalResultNum, mod_Compositing);
							if (baseResp.RespLevel != RespLevelEnum.Success)
							{
								return baseResp;
							}
							//初始化timeTicksStr
							furniture.Output_timeTicksStr = "";
						}
						else//产出到达时间大于等于当前时间
						{
							//此时状态：产出继续
							enumFurnitureOutputState = EnumFurnitureOutputState.Progressing;

							outputRemainSecond = Convert.ToInt32((outputTargetTime - timeNow).TotalSeconds);
							//计算到当前时间点时，已经产出了多少个产物
							if (modRecipeTimeInfo == null)
							{
								return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：不需要燃料的情况下，产出到达时间大于等于当前时间时，获取家具满足产出条件后的配方Id和单轮产出所花的时间的信息失败）" };
							}
							//可以产出的产物个数
							var resultNum = startTimenowTotalSeconds / formulationOutputCycleSecond;
							if (resultNum >= finalResultNum)
							{
								return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：不需要燃料的情况下，产出到达时间大于等于当前时间时，最终得到的产物个数非法）" };
							}
							var baseResp = furniture.CalculateFurnitureOutputChange(resultNum, mod_Compositing);
							if (baseResp.RespLevel != RespLevelEnum.Success)
							{
								return baseResp;
							}

							//对timeTicksStr重新赋值
							if (resultNum >= 1) //已经进行了1轮以上的产出（此时该值的结构必定为 开始 一个时间）
							{
								//计算开始的时刻
								furniture.Output_timeTicksStr = startTime.AddSeconds(resultNum * formulationOutputCycleSecond + suspendSeconds).Ticks.ToString();
							}
							else //还在该轮内，不做处理
							{
							}
						}
					}
				}
				else //存入了 开始|暂停，或者 开始|暂停|继续|暂停
				{
					//产出处于暂停状态，燃烧处于未燃烧
					if (!If_buring_Convert)
					{
						return new BaseResp { RespLevel = RespLevelEnum.Error, Msg = "错误3：（原因：存入了 开始|暂停，或者 开始|暂停|继续|暂停 时，一定时需要燃料的）" };
					}
					enumFurnitureOutputState = EnumFurnitureOutputState.PauseIn;
					enumFuelBurnState = EnumFuelBurnState.Unburned;

					double suspendSecond = 0; //暂停时间段
					for (int i = 0; i < tickCount; i = i + 2)
					{
						var startOrContinueTime = tickList[i];
						var suspendTime = tickList[i + 1];
						suspendSecond += (suspendTime - startOrContinueTime).TotalSeconds;
					}
					outputRemainSecond = Convert.ToInt32(finalResultNum * formulationOutputCycleSecond * 1.0 - suspendSecond);

					////对timeTicksStr重新赋值
					//if (finalResultNum >= 1)
					//{

					//}
					//else
					//{

					//}
				}
			}

			furnitureOutputInfo = new FurnitureOutputInfo
			{
				materialGoodsInfoList = furniture.GetFurnitureOutputMaterialGoodsInfoList_Convert(),
				materialCellNum = furniture.GetMod_FurnitureInfo().GetCellTotalNum_Convert(furniture.Level),
				enumFurnitureOutputState = enumFurnitureOutputState,
				outputCycleSecond = formulationOutputCycleSecond,
				outputRemainSecond = outputRemainSecond,

				If_buring_Convert = If_buring_Convert,
				FuelGoodsItemId = FuelGoodsItemId,
				enumFuelBurnState = enumFuelBurnState,
				fuelBurnCycleSecond = fuelBurnCycleSecond,
				FuelRemainNum = FuelRemainNum,
				burnRemainSecond = burnRemainSecond,

				resultItemId = furniture.Output_ResultGoodsItemId,
				resultNum = furniture.Output_ResultGoodsNum
			};

			if (JsonConfig.Value.IsTest)
			{
				//测试，记录结果日志
				string result = $"临时记录：时间：{timeNow.ToStr()}，家具产出结果：{furnitureOutputInfo.JsonSerialize()}";
				session.AppServer.Logger.Debug(result);
			}

			return new BaseResp() { RespLevel = RespLevelEnum.Success, Msg = "" };
		}
	}
}
